.class public Lcom/philzhu/www/framework/impl/AndroidMusic;
.super Ljava/lang/Object;
.source "AndroidMusic.java"

# interfaces
.implements Lcom/philzhu/www/framework/Music;
.implements Landroid/media/MediaPlayer$OnCompletionListener;


# instance fields
.field isPrepared:Z

.field mediaPlayer:Landroid/media/MediaPlayer;


# direct methods
.method public constructor <init>(Landroid/content/res/AssetFileDescriptor;)V
    .locals 7
    .parameter "assetDescriptor"

    .prologue
    .line 15
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 13
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->isPrepared:Z

    .line 16
    new-instance v0, Landroid/media/MediaPlayer;

    invoke-direct {v0}, Landroid/media/MediaPlayer;-><init>()V

    iput-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    .line 18
    :try_start_0
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {p1}, Landroid/content/res/AssetFileDescriptor;->getFileDescriptor()Ljava/io/FileDescriptor;

    move-result-object v1

    .line 19
    invoke-virtual {p1}, Landroid/content/res/AssetFileDescriptor;->getStartOffset()J

    move-result-wide v2

    .line 20
    invoke-virtual {p1}, Landroid/content/res/AssetFileDescriptor;->getLength()J

    move-result-wide v4

    .line 18
    invoke-virtual/range {v0 .. v5}, Landroid/media/MediaPlayer;->setDataSource(Ljava/io/FileDescriptor;JJ)V

    .line 21
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->prepare()V

    .line 22
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->isPrepared:Z

    .line 23
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0, p0}, Landroid/media/MediaPlayer;->setOnCompletionListener(Landroid/media/MediaPlayer$OnCompletionListener;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 27
    return-void

    .line 24
    :catch_0
    move-exception v0

    move-object v6, v0

    .line 25
    .local v6, e:Ljava/lang/Exception;
    new-instance v0, Ljava/lang/RuntimeException;

    const-string v1, "Couldn\'t load music"

    invoke-direct {v0, v1}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;)V

    throw v0
.end method


# virtual methods
.method public dispose()V
    .locals 1

    .prologue
    .line 31
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->isPlaying()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 32
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->stop()V

    .line 33
    :cond_0
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->release()V

    .line 34
    return-void
.end method

.method public isLooping()Z
    .locals 1

    .prologue
    .line 38
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->isLooping()Z

    move-result v0

    return v0
.end method

.method public isPlaying()Z
    .locals 1

    .prologue
    .line 43
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->isPlaying()Z

    move-result v0

    return v0
.end method

.method public isStopped()Z
    .locals 1

    .prologue
    .line 48
    iget-boolean v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->isPrepared:Z

    if-eqz v0, :cond_0

    const/4 v0, 0x0

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x1

    goto :goto_0
.end method

.method public onCompletion(Landroid/media/MediaPlayer;)V
    .locals 1
    .parameter "player"

    .prologue
    .line 95
    monitor-enter p0

    .line 96
    const/4 v0, 0x0

    :try_start_0
    iput-boolean v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->isPrepared:Z

    .line 95
    monitor-exit p0

    .line 98
    return-void

    .line 95
    :catchall_0
    move-exception v0

    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0
.end method

.method public pause()V
    .locals 1

    .prologue
    .line 53
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->isPlaying()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 54
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->pause()V

    .line 55
    :cond_0
    return-void
.end method

.method public play()V
    .locals 2

    .prologue
    .line 59
    iget-object v1, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v1}, Landroid/media/MediaPlayer;->isPlaying()Z

    move-result v1

    if-eqz v1, :cond_0

    .line 73
    :goto_0
    return-void

    .line 63
    :cond_0
    :try_start_0
    monitor-enter p0
    :try_end_0
    .catch Ljava/lang/IllegalStateException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1

    .line 64
    :try_start_1
    iget-boolean v1, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->isPrepared:Z

    if-nez v1, :cond_1

    .line 65
    iget-object v1, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v1}, Landroid/media/MediaPlayer;->prepare()V

    .line 66
    :cond_1
    iget-object v1, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v1}, Landroid/media/MediaPlayer;->start()V

    .line 63
    monitor-exit p0

    goto :goto_0

    :catchall_0
    move-exception v1

    monitor-exit p0
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    :try_start_2
    throw v1
    :try_end_2
    .catch Ljava/lang/IllegalStateException; {:try_start_2 .. :try_end_2} :catch_0
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_1

    .line 68
    :catch_0
    move-exception v1

    move-object v0, v1

    .line 69
    .local v0, e:Ljava/lang/IllegalStateException;
    invoke-virtual {v0}, Ljava/lang/IllegalStateException;->printStackTrace()V

    goto :goto_0

    .line 70
    .end local v0           #e:Ljava/lang/IllegalStateException;
    :catch_1
    move-exception v1

    move-object v0, v1

    .line 71
    .local v0, e:Ljava/io/IOException;
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_0
.end method

.method public setLooping(Z)V
    .locals 1
    .parameter "isLooping"

    .prologue
    .line 77
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0, p1}, Landroid/media/MediaPlayer;->setLooping(Z)V

    .line 78
    return-void
.end method

.method public setVolume(F)V
    .locals 1
    .parameter "volume"

    .prologue
    .line 82
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0, p1, p1}, Landroid/media/MediaPlayer;->setVolume(FF)V

    .line 83
    return-void
.end method

.method public stop()V
    .locals 1

    .prologue
    .line 87
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->mediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->stop()V

    .line 88
    monitor-enter p0

    .line 89
    const/4 v0, 0x0

    :try_start_0
    iput-boolean v0, p0, Lcom/philzhu/www/framework/impl/AndroidMusic;->isPrepared:Z

    .line 88
    monitor-exit p0

    .line 91
    return-void

    .line 88
    :catchall_0
    move-exception v0

    monitor-exit p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0
.end method
